package cc.ailley.prototype.shallow;

import cc.ailley.prototype.WorkExperience;

import java.util.ArrayList;

/**
 * 浅克隆
 *
 * @author ailley
 */
public class ShallowCloneResume implements Cloneable{

    // 名称
    public String name = null;

    // 年龄
    public Integer age = null;

    // 性别
    public String sex = null;

    //家庭成员
    public ArrayList<String> familyMember = new ArrayList<>();

    // 工作经验

    public WorkExperience work = null;

    public ShallowCloneResume(String name, ArrayList<String> familyMember) {
        this.name = name;
        this.familyMember = familyMember;
        work = new WorkExperience();
    }

    public void setName(String name) {
        this.name = name;
    }// setName

    public void setPersonal(String sex, int age) {
        this.age = age;
        this.sex = sex;
    }// setPersonal

    public void setWork(String timeArea, String company) {
        work.timeArea = timeArea;
        work.company = company;
    }// setWork

    @Override
    protected ShallowCloneResume clone() throws CloneNotSupportedException {
        return (ShallowCloneResume) super.clone();
    }

    public void display() {
        System.out.println(this.name + " " + this.sex + " " + this.age);
        System.out.print("Family member: ");
        for(String elem : familyMember)
            System.out.print(elem + " ");
        System.out.println();
        System.out.print("Work experience: " + this.work.timeArea);
        System.out.println(" " + this.work.company);
    }// display
}
